package com.itm.lqm.servlets.grade;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.itm.lqm.entity.Grade;
import com.itm.lqm.service.GradeService;

/**
 * Servlet implementation class addGrade
 */
@WebServlet("/addGrade")
public class addGrade extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public addGrade() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	/*	// 获取添加页面的请求参数，然后调用业务逻辑层对象，实现最终修改
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");

		int gid = Integer.parseInt(request.getParameter("gid"));
		int usualG = Integer.parseInt(request.getParameter("usualG"));
		int finalG = Integer.parseInt(request.getParameter("finalG"));
		int overallG = Integer.parseInt(request.getParameter("overallG"));
		String sname = request.getParameter("sname");
		String cname = request.getParameter("cname");
		String sno = request.getParameter("sno");
		String clas = request.getParameter("clas");

		Grade g = new Grade(gid,usualG, finalG, overallG,sname,cname,sno,clas);
		System.out.println(g);
		GradeService gs = new GradeService();

		boolean result = gs.addGrade(g);

		System.out.println(result);
		if (result) {
			// request.getRequestDispatcher("a.jsp").forward(request, response);
			request.getRequestDispatcher("findAllGrade").forward(request, response);

		} else {
			// response.sendRedirect("addCourse.jsp");
		}*/
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 获取添加页面的请求参数，然后调用业务逻辑层对象，实现最终修改
			/*	request.setCharacterEncoding("UTF-8");
				response.setCharacterEncoding("UTF-8");
				response.setContentType("text/html; charset=UTF-8");

				int gid = Integer.parseInt(request.getParameter("gid"));
				int usualG = Integer.parseInt(request.getParameter("usualG"));
				int finalG = Integer.parseInt(request.getParameter("finalG"));
				int overallG = Integer.parseInt(request.getParameter("overallG"));
				String sname = request.getParameter("sname");
				String cname = request.getParameter("cname");
				String sno = request.getParameter("sno");
				String clas = request.getParameter("clas");

				Grade g = new Grade(gid,usualG, finalG, overallG,sname,cname,sno,clas);
				System.out.println(g);
				GradeService gs = new GradeService();

				boolean result = gs.addGrade(g);

				System.out.println(result);
				if (result) {
					// request.getRequestDispatcher("a.jsp").forward(request, response);
					request.getRequestDispatcher("findAllGrade").forward(request, response);

				} else {
					// response.sendRedirect("addCourse.jsp");
*/			//	}
	}

}
